<?php

$thisModule = "services";
$activeSearchTab = "services";

TemplateHelper::useLayout("links");

loadJQueryPlugin("innerfade");
loadJQueryPlugin("servicedropdown");
loadJQueryPlugin("submitter");
loadJQueryPlugin("imghover");

addDataservice("getimgtext");

function buildLayout(&$smarty) {

    $smarty->assign("newwindow", true);
    $smarty->assign("defaulttext", "Search for recommended services");
    initDatabase();
    Database::loadModel("companies");
    $companies = Database::getModel()->getRotatorCompaniesFor("service");
    $pictures = array(
        array(src => "site/layout/searchscreen/resources/img/agendarium_logo.png", href => "http://www.lancasterconsulting.hu"),
        array(src => "site/layout/searchscreen/resources/img/youcv_banner_2.jpg", href => "http://www.lancasterconsulting.hu"),
        array(src => "site/layout/searchscreen/resources/img/budapest_banner.jpg", href => "http://www.exporthungary.hu"),
        array(src => "site/layout/searchscreen/resources/img/empty_rotator.png", href => "index.php?choice=mediaoffer"),
    );
    $counter = 0;
    for ($i = 0; $i < count($companies) && $i < 4; $i++) {
        if ($i == 1) { $counter++; }
        $pictures[$counter]['src'] = callFileloaderDisplayCompanyFile("export", "rotator", $companies[$i]['company_id']);
        $pictures[$counter]['href'] = $companies[$i]['hphungarian'];
        $counter++;
        if ($counter >= 4) { break; }
    }
    $smarty->assign("searchcontent", getSearchScreen());
    $smarty->assign("activesearchtab", getActiveSearchTab());
    $smarty->assign("pictures", $pictures);
    $smarty->assign("newwindow", false);
    $links = array();
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 1)),  title => "Accounting, Auditing");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 2)),  title => "Advertising and PR agencies");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 3)),  title => "Air tickets, Airlines, Travel agencies");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 4)),  title => "Art, Entertainment");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 5)),  title => "Attorneys");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 6)),  title => "Banks, Insurance companies");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 7)),  title => "Beauty salons, Skincare, Hair, Cosmetics");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 8)),  title => "Car importers, Fleet management");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 9)),  title => "Debt management, Security, Telecommunication");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 10)), title => "Computers, Software, Printing, Office supply");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 11)), title => "Conference centers");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 12)), title => "Courier and messenger services");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 13)), title => "Customs agents");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 14)), title => "Event organizers, Catering, Hostess services");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 15)), title => "Sport, Fitness clubs");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 16)), title => "Florists, Gardening, Cleaning services");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 17)), title => "Furniture, home decoration");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 18)), title => "Healthcare and pharmacies");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 19)), title => "Hotels");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 20)), title => "Logistic services, Relocation");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 21)), title => "Market research, Translation");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 22)), title => "Real estate");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 23)), title => "Recruiting and HR services");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 24)), title => "Restaurants");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 25)), title => "Schools and universities, Books");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 26)), title => "Shopping");
    $links[] = array(href => buildRedirectUrl("list_services", "", array(selectedService => 27)), title => "Taxi, Car rental");
    $smarty->assign("links", $links);
}

function executeService($serviceName, $params, $smarty) {
    switch ($serviceName) {
        case "getavailableservices" : { return service_getavailableservices($params); break; }
        case "getimgtext" : { return service_getimgtext($params, $smarty); break; }
    }
}

function service_getavailableServices($params) {
    $serviceList = array();
    $serviceList[] = array(text => "Accounting, Auditing");
    $serviceList[] = array(text => "Advertising and PR agencies");
    $serviceList[] = array(text => "Air tickets, Airlines, Travel agencies");
    $serviceList[] = array(text => "Art, Entertainment");
    $serviceList[] = array(text => "Attorneys");
    $serviceList[] = array(text => "Banks, Insurance companies");
    $serviceList[] = array(text => "Beauty salons, Skincare, Hair, Cosmetics");
    $serviceList[] = array(text => "Car importers, Fleet management");
    $serviceList[] = array(text => "Debt management, Security, Telecommunication");
    $serviceList[] = array(text => "Computers, Software, Printing, Office supply");
    $serviceList[] = array(text => "Conference centers");
    $serviceList[] = array(text => "Courier and messenger services");
    $serviceList[] = array(text => "Customs agents");
    $serviceList[] = array(text => "Event organizers, Catering, Hostess services");
    $serviceList[] = array(text => "Sport, Fitness clubs");
    $serviceList[] = array(text => "Florists, Gardening, Cleaning services");
    $serviceList[] = array(text => "Furniture, home decoration");
    $serviceList[] = array(text => "Healthcare and pharmacies");
    $serviceList[] = array(text => "Hotels");
    $serviceList[] = array(text => "Logistic services, Relocation");
    $serviceList[] = array(text => "Market research, Translation");
    $serviceList[] = array(text => "Real estate");
    $serviceList[] = array(text => "Recruiting and HR services");
    $serviceList[] = array(text => "Restaurants");
    $serviceList[] = array(text => "Schools and universities, Books");
    $serviceList[] = array(text => "Shopping");
    $serviceList[] = array(text => "Taxi, Car rental");
    return serviceSuccessful(array(
        items => $serviceList,
    ));
}

function service_getimgtext($params, $smarty) {
    global $thisModule;

    Database::loadModel("companies");
    $result = Database::getItem($params['company_id']);
    $smarty->assign("companydata", $result);
    return serviceSuccessful(array(
        html => $smarty->fetch(TemplateHelper::getTemplateFile($thisModule, "imagetext"))
    ));
}



function getPageHeader() {
    return TemplateHelper::getDefaultPageHeader();
}

function getPageFooter() {
    return TemplateHelper::getDefaultPageFooter();
}

function getSearchScreen() {
    global $smarty;
    global $thisModule;

    $templateFile = TemplateHelper::getTemplateFile($thisModule, "svc_search");
    return $smarty->fetch($templateFile);
}

function getActiveSearchTab() {
    global $activeSearchTab;
    
    return $activeSearchTab;
}

?>
